Conversation
…nditionals
Ansible 2.19 tightened conditional evaluation and now rejects expressions
like `default({'changed': false})` inside a `when:` with "Conditional
expressions must be strings." Replace the dict-literal default with an
attribute-level default, which is semantically equivalent and parses under
both 2.18 and 2.19.
Closes #139
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated conditional expressions in Elasticsearch handlers to resolve Ansible 2.19 strict conditionals compatibility. Replaced dict-literal defaults with attribute-level defaults across four handlers, changing from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #139.
Ansible 2.19 tightened conditional evaluation so expressions like
default({'changed': false})inside awhen:clause now fail withConditional expressions must be strings.. The restart handlers in #137 all used that pattern to guard against the freshstart facts being undefined. Swapped to an attribute-level default (.changed | default(false) | bool), which is semantically equivalent — both forms returnfalse(don't block the restart) when the fact is undefined or when.changedis missing — and parses cleanly under both 2.18 and 2.19.The
elasticsearch_defaultscenario'sside_effect.ymlalready exercises the Restart Elasticsearch handler end-to-end on a 2-node cluster, so the code path is covered. Note that CI still pinsansible-core<2.19because of the unrelatedrole_pathscoping change blocking that upgrade, so 2.19-strict mode is not yet directly exercised by CI — the fix is equivalent on 2.18.Scope is intentionally narrow to what #139 calls out. Other
default({})usages (inuntil:clauses across tasks) use empty-dict literals, not key-value dicts, and haven't been reported as failing; leaving those alone until we can actually run 2.19 in CI.Summary by CodeRabbit